package com.baidu.cmsService.dao;

import com.baidu.cmsCommes.pojo.Role;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Author: BSS
 * @create: 2020/6/18/15:20
 */
@Mapper
public interface RoleDao {
    @Select("select * from t_role")
    List<Role> roleList();

    @Select("select * from t_role where id = #{rid}")
    @Results({@Result(property="id",column="id")
            ,@Result(property="name",column="name")
            ,@Result(property="roleType",column="role_type")
    })
    Role selectById(@Param("rid") Integer rid);

    @Insert("insert into t_role value(#{role.id},#{role.name},#{role.roleType})")
    @Options(useGeneratedKeys = true,keyColumn = "t_role.id",keyProperty = "role.id")
    @ResultType(Integer.class)
    Integer saveRole(@Param("role") Role role);

    @Delete("delete from t_role where id = #{rid}")
    Integer deleteRole(@Param("rid") Integer rid);

    @Update("update t_role set name = #{role.name},role_type=#{role.roleType} where id = #{role.id}")
    Integer updateRole(@Param("role") Role role);
}
